package bb.lanxing.devices.sync;

import bb.lanxing.lib.devices.core.sync.DeviceFile;
import bb.lanxing.lib.devices.core.sync.FitDeviceFile;
import bb.lanxing.lib.devices.core.utils.DeviceHelper;
import bb.lanxing.lib.devices.sprint.sync.AbstractSprintHistorySyncManager;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class XossGHistoryManager extends AbstractSprintHistorySyncManager {
    public XossGHistoryManager(String str) {
        super(str, DeviceHelper.getWorkDir(17));
        String workDir = DeviceHelper.getWorkDir(17);
        DefaultFitProcessor defaultFitProcessor = new DefaultFitProcessor(5);
        defaultFitProcessor.setAddress(str);
        init(workDir, defaultFitProcessor);
    }

    @Override    public void setDeviceFiles(List<DeviceFile> list) {
        Collections.sort(list, new Comparator<DeviceFile>() {
            @Override
            public int compare(DeviceFile deviceFile, DeviceFile deviceFile2) {
                return ((int) (((FitDeviceFile) deviceFile).getStartTime() / 1000)) - ((int) (((FitDeviceFile) deviceFile2).getStartTime() / 1000));
            }
        });
        super.setDeviceFiles(list);
    }

    @Override
    public void deleteAll() {
        for (DeviceFile deviceFile : getDeviceFiles()) {
            getController().delete(deviceFile.getName());
        }
    }
}
